package com.lcx.controller;


import com.lcx.config.R;
import com.lcx.entity.Swiper;
import com.lcx.entity.dto.addDto;
import com.lcx.service.ISwiperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2023-11-16
 */
@RestController
@RequestMapping("/swiper")
public class SwiperController {
    
    @Autowired
    private ISwiperService service;
    
    @PostMapping("/addSwiper")
    public R add (@RequestBody addDto addDto) {
        addDto.setImgUrl("metest/轮播图/"+addDto.getImgUrl());
        Swiper swiper = new Swiper().setMusicsId(addDto.getName()).setSwiperPath(addDto.getImgUrl());
        swiper.setType("image");
        return R.okResult(service.saveOrUpdate(swiper));
    }
    @GetMapping("/deleteSwiper")
    public R delete (@RequestParam("id") Integer id) {
        return R.okResult(service.removeById(id));
    }
}
